package apiday02homework;

public class IntegerDemo {
    public static void main(String[] args) {
        Integer i1 = new Integer(10);
        Integer i2 = new Integer("10");
        //false
        System.out.println(i1 == i2);
        //true，包装类重写equals()比较值了
        System.out.println(i1.equals(i2));
        System.out.println("-----------------------------------");
        //valueOf()方法会复用1个字节(-128到127)范围内的数据，建议使用valueOf()
        Integer i3 = Integer.valueOf(10);
        Integer i4 = Integer.valueOf(10);
        System.out.println(i3 == i4);
        System.out.println(i3.equals(i4));

        System.out.println("-----------------------------------");
        //基本类型转换为包装类型
        Integer i5 = Integer.valueOf(10);
        //包装类型转换为基本类型
        int j = i5.intValue();
        System.out.println(j);
        System.out.println("-----------------------------------");

        int max = Integer.MAX_VALUE;
        int min = Integer.MIN_VALUE;
        System.out.println(max + "," + min);

        long maxLong = Long.MAX_VALUE;
        long minLong = Long.MIN_VALUE;
        System.out.println(maxLong + "," + minLong);
        System.out.println("-----------------------------------");
//包装类可以将字符串转换为对应的基本类型
        String s1 = "39";
        int age = Integer.parseInt(s1);
        System.out.println(age);

        String s2 = "3.14";
        double price = Double.parseDouble(s2);
        System.out.println(price);
        System.out.println("-----------------------------------");
        Integer i6 = 3;
        int j1 = i6;
        System.out.println(j1);

    }
}
